﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Client
{
    public partial class WaitingScreen : Form
    {
      
        StreamReader streamReader;
        public WaitingScreen(StreamReader sr)
        {
            InitializeComponent();
            streamReader = sr;
            backgroundWorker1.RunWorkerAsync();
            
            

        }

     

        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            Console.WriteLine("Doing work");
            string input = streamReader.ReadLine();
            Console.WriteLine("Doing work done");
            SafeClose();
            
        }
        public void SafeClose()
        {
            // Make sure we're running on the UI thread
            if (this.InvokeRequired)
            {
                BeginInvoke(new Action(SafeClose));
                return;
            }

            // Close the form now that we're running on the UI thread
            Close();
        }


    

    }
}
